package Bacterias;

import android.util.Log;

import com.game.ThauanFramework.TimeManager;

public class ForShakeRunnable implements Runnable {

	private final String TAG = "For Shake Runnable";
	private final int interval = 10;
	public boolean isAlive = true;

	private double cronometer = 0;
	private double timeBeforeEnable = 0;

	private Bac bac;

	public void setAlive(boolean isAlive) {
		this.isAlive = isAlive;
	}

	public ForShakeRunnable(Bac bac, double timeBefore) {
		this.bac = bac;
		this.timeBeforeEnable = timeBefore;

		Thread thread = new Thread(this);
		thread.start();
	}

	@Override
	public void run() {
		while (isAlive) {

			try {
				Thread.sleep(interval);
			} catch (InterruptedException e) {
				Log.e(TAG, "Erro na Runnable de For Shake");
				e.printStackTrace();
			}

			cronometer += TimeManager.getInstance().getDeltaTime();

			if (cronometer >= this.timeBeforeEnable) {
				this.bac.setShake(true);
				this.setAlive(false);
			}
		}
	}
}
